package org.example;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-11-02
 * 21:07
 */
import java.util.Scanner;
class Test{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] arr=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        int k=0;
        k=arr[1]-arr[0];
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                int k1=arr[j]-arr[i];
                if(k1>k){
                    k=k1;
                }
            }
        }
        System.out.println(k);
    }
}